﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:skin="clr-namespace:UBCon.Ribbon.SkinManagers"
                    xmlns:ubcr="clr-namespace:UBCon.Ribbon">

    <ControlTemplate TargetType="{x:Type ubcr:RibbonTabItem}"
                     x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ubcr:RibbonTabItem}, ResourceId=DefaultRibbonTabItemTemplate}">
        <Grid x:Name="PART_TabItemToot"
              Height="23"  
              Focusable="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="23" />
                <RowDefinition Height="0" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Path StrokeThickness="1" 
                  Margin="0,0.6,-2,0" 
                  SnapsToDevicePixels="False"
                  Grid.Column="0" 
                  Focusable="False" 
                  x:Name="Left" 
                  Data="M 0,23 L 3,20 L3,3 A 3,3 45 0,1 6,0 L 7,0 L 7,23"
                  Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                  Stroke="{TemplateBinding BorderBrush}" Opacity="0" />
            <Path StrokeThickness="1" 
                  Margin="-1,0.6,0,0" 
                  SnapsToDevicePixels="False"
                  Grid.Column="2" Focusable="False" 
                  x:Name="Right" 
                  Data="M0,23 L 0,0 L 1,0 A 3,3 45 0,1 4,3 L 4,20 L7,23"
                  Fill="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=WhiteBrush}}"
                  Stroke="{TemplateBinding BorderBrush}" Opacity="0" />
            <Border Focusable="False" x:Name="PART_HeaderBorder" BorderThickness="1, 1, 1, 0" Grid.Column="1">
                <Border x:Name="MouseHoveBorder" 
                        Focusable="False" 
                        BorderThickness="0.5, 0.5, 0.5, 0"
                        BorderBrush="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=TransparentBrush}}" Padding="11,0,11,0">
                </Border>
            </Border>
            <Border Grid.Column="1" 
                    Padding="10, 0, 10, 0">
                <TextBlock  x:Name="HeaderText" 
                            Text="{TemplateBinding Header}"  
                            HorizontalAlignment="Left" 
                            TextAlignment="Center" 
                            TextTrimming="CharacterEllipsis" 
                            VerticalAlignment="Center"/>
            </Border>
        </Grid>
        <ControlTemplate.Triggers>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsBackgroundModeEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonBar}}}" Value="True" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=Self}}" Value="True" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="BorderBrush" Value="White" TargetName="MouseHoveBorder" />
                    <Setter Property="BorderBrush" Value="{DynamicResource ResourceKey={ComponentResourceKey TypeInTargetAssembly={x:Type skin:SkinManager}, ResourceId=SelectedBorderBrush}}" 
                        TargetName="PART_HeaderBorder"/>
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>
            <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding Path=IsBackgroundModeEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ubcr:RibbonBar}}}" Value="False" />
                    <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Mode=Self}}" Value="True" />
                </MultiDataTrigger.Conditions>
                <MultiDataTrigger.Setters>
                    <Setter Property="Opacity" Value="1"
                        TargetName="Left"/>
                    <Setter Property="Opacity" Value="1"
                        TargetName="Right"/>
                    <Setter Property="BorderThickness" Value="0,1,0,0" 
                        TargetName="PART_HeaderBorder"/>
                    <Setter Property="Background" Value="White" 
                        TargetName="PART_HeaderBorder"/>
                    <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=skin:SkinManager, ResourceId=SelectedBorderBrush}}" 
                        TargetName="PART_HeaderBorder"/>
                </MultiDataTrigger.Setters>
            </MultiDataTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSelected" Value="False"/>
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="BorderBrush" Value="White" TargetName="MouseHoveBorder" />
                    <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=skin:SkinManager, ResourceId=SelectedBorderBrush}}" 
                        TargetName="PART_HeaderBorder"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
</ResourceDictionary>